package com.alibaba.basic.config;

import com.alibaba.basic.interceptor.LoginInterceptor;
import com.alibaba.user.mapper.LogininfoMapper;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;
import javax.imageio.spi.RegisterableService;

@Configuration //表示此类为配置类(配置请求路径的黑白名单)
public class WebConfigurer implements WebMvcConfigurer {

    @Resource
    private LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // addPathPatterns("/**") 表示拦截所有的请求，
        // excludePathPatterns("/login", "/register") 表示除了登陆与注册之外，因为登陆注册不需要登陆也可以访问

        registry.addInterceptor(loginInterceptor).addPathPatterns("/**")
                .excludePathPatterns("/login/**")
                .excludePathPatterns("/register/**")
                .excludePathPatterns("/verifyCode/**")
                .excludePathPatterns("/fastDfs/**")
                .excludePathPatterns("/user/phone/register/**")
                .excludePathPatterns("/user/email/register/**")
                .excludePathPatterns("/shop/settlement/**")
                .excludePathPatterns("/shop/register/**");
    }

}
